<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Statistic extends CI_Controller {

	function __construct() {
        parent::__construct();
        
        $this->title = "SMILE | Selamat datang, telkom siap melayani Anda!";
        
        $this->load->helper(array('date', 'url', 'excel_helper', 'MY_date_helper', 'chart_helper', 'math_helper'));
        
        //$this->scripts = array("jquery", "jquery-ui", "statistic", "fusionchart/FusionCharts", "fusionchart/chart_helper", "fusionchart/FusionChartsExportComponent", );
        $this->scripts = array("jquery", "jquery-ui", "statistic","ofc2/swfobject","ofc2/json2");
        $this->styles = array("jquery-ui","useradmin");
		
    }
	
	public function index(){
		$this->view2();
	} 
	
	public function view2(){
		
        if($this->session->userdata('is_super_admin')||$this->session->userdata('is_admin')||$this->session->userdata('is_pic')){
            
        }else{
            redirect('admin/site/login');
        }
		
		$is_super_admin = $this->session->userdata('is_super_admin'); 
		$is_admin = $this->session->userdata('is_admin'); 
		$is_pic = $this->session->userdata('is_pic'); 
		
		$menudata['is_super_admin'] = $is_super_admin;
		$menudata['is_admin'] = $is_admin;
		$menudata['is_pic'] = $is_pic;
		$this->menubar = $this->load->view('admin/menubar',$menudata);
		
		$questions = $this->questionmodel->get_all_question()->result_array();
		$data["questions"] = $questions;
		
		$plasa = null;
		$plasa_name = '';
		$csr = null;
		if($is_super_admin)	$plasa = $this->plasamodel->get_all_plasa()->result_array();
		else if($is_admin)	$plasa = $this->session->userdata('is_admin'); 
		else if($is_pic)	$plasa = $this->session->userdata('is_pic');
		
		if($is_admin || $is_pic){
			$plasa_name = $this->plasamodel->get_plasa_info($plasa)->row()->name;
			$csr = $this->csrmodel->get_all_csr_by_plasa($plasa)->result_array();
		}
		
		$data["plasa"] = $plasa;
		$data["plasa_name"] = $plasa_name;
		$data["csr"] = $csr;
		
		$data["chart_url"] = base_url() . "admin/statistic/satisfaction_ajax_chart";
		$data["chart_type"] = base_url() . "assets/swf/FCF_Pie3D.swf";
		$data["table"] = "none";
		
		$this->layout = "admin";
		$this->load->view('admin/statistic2', $data);
	}
	
	function get_available_time(){
		$this->layout = false;
		
		$questions = json_decode($this->input->post('q_id'));
		$plasa_id = $this->input->post('plasa_id') > 0 ? $this->input->post('plasa_id') : null;
		$csr_id = $this->input->post('csr_id') > 0 ? $this->input->post('csr_id') : null;
		
//		print_r($questions);
//		echo '+'.$csr_id. ' + '.$plasa_id;
		echo json_encode($this->respondmodel->get_year_available($questions, $plasa_id, $csr_id));
	}
	
	function dummy(){
//		print_r($this->respondmodel->get_year_available($questions, $plasa_id, $csr_id));
	}
	
    function get_csr($plasa_id) {
        $this->layout = false;

        $result = $this->csrmodel->get_all_csr_by_plasa($plasa_id);
        echo json_encode($result->result_array());
    }
	
	function get_data_pie($timeType, $param1, $param2, $param3 = null, $plasa_id = 0, $csr_id = 0){
		$this->layout = false;
        $this->load->library('Ofc2factory', NULL, 'ofc2');

		//retrieve data
		$question_id = ($timeType == 2 ? $param2 : $param3);
		$question = $this->questionmodel->get_info_question($question_id)->row();
		
		$starttime = "00:00:00";
		$endtime = "23:59:59";
		
		$start_datetime = "";
		$end_datetime = "";
		
		if($timeType == 0){ // harian
			if(is_date_after($param2, $param1)){
				$temp = $param2;
				$param2 = $param1;
				$param1 = $temp;
			}
			$start_datetime = $param1.' '.$starttime;
			$end_datetime =  $param2.' '.$endtime;
		}else if($timeType == 1){ // bulanan
			$first_date = $param2.'-'.$param1.'-01';
			$end_date = plus_month($first_date, 1);
			
			$start_datetime = $first_date.' '.$starttime;
			$end_datetime =  $end_date.' '.$endtime;
		}else if($timeType == 2){ //tahunan
			$start_datetime = $param1.'-01-01 '.$starttime;
			$end_datetime =  $param1.'-12-31 '.$endtime;
		}
		//echo $start_datetime.' '.$end_datetime;
		
		$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $start_datetime, $end_datetime, ($timeType == 1 ? false : true), ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $start_datetime, $end_datetime, ($timeType == 1 ? false : true), ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$totalCount = $countSatisfied + $countNotSatisfied;
		
		$content_title = '';
		
		if($totalCount == 0) {
			$totalCount = 1;
			$content_title = "Tidak ada data pada rentang waktu tersebut";
		}else{
			if($timeType == 0){ // harian
				$content_title = $question->content.' <br>('. to_idformat($param1) . ' - ' . to_idformat($param2).')';
			}else if($timeType == 1){ // bulanan
				$content_title = $question->content.' <br>(Bulan '. get_month_name($param1, LANG_INDONESIA) . ' ' . $param2.')';
			}else if($timeType == 2){ //tahunan
				$content_title = $question->content.' <br>('.$param1.')';
			}
		}
		
		$title = new title($content_title);
		$title->set_style( "{font-size: 12px; color: #162E5A; text-align: center;}" );
        
		$pie_valueobj = array(
			new pie_value($countSatisfied, GRAPH_TEXT_YES.', '.$countSatisfied.'('.round($countSatisfied/$totalCount*100, 1).'%)'),
			new pie_value($countNotSatisfied, GRAPH_TEXT_NO.', '.$countNotSatisfied.'('.round($countNotSatisfied/$totalCount*100, 1).'%)')
		);
		
		$pie = new pie();
		$pie->set_start_angle( 0 );
		$pie->alpha(0.7);
		$pie->set_animate(true );
		$pie->add_animation( new pie_bounce(9) );
		$pie->set_tooltip( '#label#<br>#val# of #total#<br>#percent# of 100%' );
		$pie->set_values( $pie_valueobj);
		$pie->set_colours( array(GRAPH_COLOR_YES, GRAPH_COLOR_NO));
		$chart = new open_flash_chart();
		$chart->set_title( $title );
		$chart->add_element( $pie );
		$chart->set_bg_colour('#eeeeee');
		$chart->x_axis = null;

		
        echo $chart->toPrettyString();
    }
		
	function get_data_table($timeType, $param1, $param2, $param3 = null, $plasa_id = 0, $csr_id = 0, $for_ajax = true){
		$this->layout = false;
		//retrieve data
		$question_id = ($timeType == 2 ? $param2 : $param3);
		
		$starttime = "00:00:00";
		$endtime = "23:59:59";
			
		
		$start_datetime = "";
		$end_datetime = "";
		
		$dataHeader = array();
		$dataSatisfied = array();
		$dataNotSatisfied = array();
		$dataPercent = array();
		$dataTotal = 0;	
		
		if($timeType == 0){ // harian
			if(is_date_after($param2, $param1)){
				$temp = $param2;
				$param2 = $param1;
				$param1 = $temp;
			}
			
			$dateBetween = get_date_between($param1,$param2);
			foreach ($dateBetween as $date){
				$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				$totalCount = $countSatisfied + $countNotSatisfied;
				if ($totalCount == 0) $totalCount = 1;
				
				array_push($dataHeader, to_idformat($date));
				array_push($dataSatisfied, $countSatisfied);
				array_push($dataNotSatisfied, $countNotSatisfied);
				array_push($dataPercent, round($countSatisfied/$totalCount*100, 1));
				$dataTotal++;
			}
		}else if($timeType == 1){ // bulanan
			$first_date = $param2.'-'.$param1.'-01';
			$end_date = plus_month($first_date, 1);
			$dateBetween = get_date_between($first_date, $end_date);
			array_pop($dateBetween);
			$dateBetween_format = array();
			foreach ($dateBetween as $date){
				$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				$totalCount = $countSatisfied + $countNotSatisfied;
				if ($totalCount == 0) $totalCount = 1;
				
				array_push($dataHeader, to_idformat($date));
				array_push($dataSatisfied, $countSatisfied);
				array_push($dataNotSatisfied, $countNotSatisfied);
				array_push($dataPercent, round($countSatisfied/$totalCount*100, 1));
				$dataTotal++;
			}
		}else if($timeType == 2){ //tahunan
			for($i = 1; $i <= 12; $i++){
				$first_datetime = $param1.'-'.$i.'-01';
				$end_datetime = plus_month($first_datetime, 1);
				$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $first_datetime.' '.$starttime, $end_datetime.' '.$starttime, false, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $first_datetime.' '.$starttime, $end_datetime.' '.$starttime, false, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
				
				$totalCount = $countSatisfied + $countNotSatisfied;
				if ($totalCount == 0) $totalCount = 1;
				
				array_push($dataSatisfied, $countSatisfied);
				array_push($dataNotSatisfied, $countNotSatisfied);
				array_push($dataPercent, round($countSatisfied/$totalCount*100, 1));
				$dataTotal++;
			}
			$dataHeader = get_array_month(LANG_INDONESIA);
		}
		
		$respond = array(
			'tHeader'	=> $dataHeader,
			'tYes'		=> $dataSatisfied,
			'tNo'		=> $dataNotSatisfied,
			'tPercent'	=> $dataPercent,
			'total'		=> $dataTotal
		);
		
		if($for_ajax)	echo json_encode($respond);
		else return json_encode($respond);
	}
	
	function get_daily_data($from, $to, $question_id, $plasa_id = 0, $csr_id = 0 ){
		$this->layout = false;
        $this->load->library('Ofc2factory', NULL, 'ofc2');

		
		//retrieve data
		$question = $this->questionmodel->get_info_question($question_id)->row();
		
		$content_title = '';
		$starttime = "00:00:00";
		$endtime = "23:59:59";
		
		//validate if date is reversed
		if(is_date_after($to, $from)){
			$temp = $from;
			$from = $to;
			$to = $temp;
		}
		
		//get date between
		$dateBetween = get_date_between($from,$to);
		
		//count total respond
		$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $from.' '.$starttime, $to.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $from.' '.$starttime, $to.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$totalCount = $countSatisfied + $countNotSatisfied;
		
		//set title
		if($totalCount == 0) {
			$totalCount = 1;
			$content_title = "Tidak ada data pada rentang waktu tersebut";
		}else{
			$content_title = $question->content.' <br>('. to_idformat($from) . ' - ' . to_idformat($to).')';
		}
		
		$title = new title($content_title);
		$title->set_style( "{font-size: 12px; color: #F24062; text-align: center;}" );

		//init bar
		$bar_stack = new bar_stack();

		$bar_stack->set_colours( array( '#C4D318', '#50284A' ) );
		$bar_stack->set_keys(array(
				new bar_stack_key( '#C4D318', 'Ya', 13 ),
				new bar_stack_key( '#50284A', 'Tidak', 13 )
				));

		//get date between in format + add stack
		$highest = 0;
		$dateBetween_format = array();
		foreach ($dateBetween as $date){
			array_push($dateBetween_format, to_idformat($date));
			
			$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			$bar_stack->append_stack(array($countSatisfied,$countNotSatisfied));
			
			if ($countNotSatisfied + $countSatisfied > $highest) $highest = $countNotSatisfied + $countSatisfied + 3;
		}
		
		$bar_stack->set_tooltip( '[#x_label#]<br>#val# dari #total# responder' );

		$animation='pop'; $delay=0; $cascade=1;
		$bar_stack->set_on_show(new bar_on_show($animation, $cascade, $delay));

		$y = new y_axis();
		$y->set_range( 0, roundup_integer($highest), 10 );


		$x_labels = new x_axis_labels();
		$x_labels->rotate(20);
		$x_labels->set_labels($dateBetween_format);
		$x = new x_axis();
		$x->set_labels($x_labels);

		$tooltip = new tooltip();
		$tooltip->set_hover();

		$chart = new open_flash_chart();
		$chart->set_title( $title );
		$chart->add_element( $bar_stack );
		$chart->set_x_axis( $x );
		$chart->add_y_axis( $y );
		$chart->set_tooltip( $tooltip );

		echo $chart->toPrettyString();
	}
	
	function get_weekly_data($month, $year, $question_id, $plasa_id = 0, $csr_id = 0 ){
		$this->layout = false;
        $this->load->library('Ofc2factory', NULL, 'ofc2');

		
		//retrieve data
		$question = $this->questionmodel->get_info_question($question_id)->row();
		
		$content_title = '';
		$starttime = "00:00:00";
		$endtime = "23:59:59";
		
		//get date between
		$first_date = $year.'-'.$month.'-01';
		$end_date = plus_month($first_date, 1);
		$dateBetween = get_date_between($first_date, $end_date);
		array_pop($dateBetween);
		
		//count total respond
		$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $first_date.' '.$starttime, $end_date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $first_date.' '.$starttime, $end_date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$totalCount = $countSatisfied + $countNotSatisfied;
		
		//set title
		if($totalCount == 0) {
			$totalCount = 1;
			$content_title = "Tidak ada data pada rentang waktu tersebut";
		}else{
			$content_title = $question->content.' <br>(Bulan '. get_month_name($month, LANG_INDONESIA) . ' ' . $year.')';
		}
		
		$title = new title($content_title);
		$title->set_style( "{font-size: 12px; color: #F24062; text-align: center;}" );

		//init bar
		$bar_stack = new bar_stack();

		$bar_stack->set_colours( array( '#C4D318', '#50284A' ) );
		$bar_stack->set_keys(array(
				new bar_stack_key( '#C4D318', 'Ya', 13 ),
				new bar_stack_key( '#50284A', 'Tidak', 13 )
				));

		//get date between in format + add stack
		$highest = 0;
		$dateBetween_format = array();
		foreach ($dateBetween as $date){
			array_push($dateBetween_format, to_idformat($date));
			
			$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $date.' '.$starttime, $date.' '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			$bar_stack->append_stack(array($countSatisfied,$countNotSatisfied));
			
			if ($countNotSatisfied + $countSatisfied > $highest) $highest = $countNotSatisfied + $countSatisfied + 3;
		}
		
		$bar_stack->set_tooltip( '[#x_label#]<br>#val# dari #total# responder' );

		$animation='pop'; $delay=0; $cascade=1;
		$bar_stack->set_on_show(new bar_on_show($animation, $cascade, $delay));

		$y = new y_axis();
		$y->set_range( 0, roundup_integer($highest), 10 );


		$x_labels = new x_axis_labels();
		$x_labels->rotate(20);
		$x_labels->set_labels($dateBetween_format);
		$x = new x_axis();
		$x->set_labels($x_labels);

		$tooltip = new tooltip();
		$tooltip->set_hover();

		$chart = new open_flash_chart();
		$chart->set_title( $title );
		$chart->add_element( $bar_stack );
		$chart->set_x_axis( $x );
		$chart->add_y_axis( $y );
		$chart->set_tooltip( $tooltip );

		echo $chart->toPrettyString();
	}
	
	function get_monthly_data($year, $question_id, $dummy = null, $plasa_id = 0, $csr_id = 0 ){
		$this->layout = false;
        $this->load->library('Ofc2factory', NULL, 'ofc2');

		//retrieve data
		$question = $this->questionmodel->get_info_question($question_id)->row();
		
		$content_title = '';
		$starttime = "00:00:00";
		$endtime = "23:59:59";
		
		//count total respond
		$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $year.'-01-01 '.$starttime, $year.'-12-31 '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $year.'-01-01 '.$starttime, $year.'-12-31 '.$endtime, true, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
		$totalCount = $countSatisfied + $countNotSatisfied;
		
		//set title
		if($totalCount == 0) {
			$totalCount = 1;
			$content_title = "Tidak ada data pada rentang waktu tersebut";
		}else{
			$content_title = $question->content.' <br>('.$year.')';
		}
		
		$title = new title($content_title);
		$title->set_style( "{font-size: 16px; color: #F24062; text-align: center;}" );

		//init bar
		$bar_stack = new bar_stack();

		$bar_stack->set_colours( array( '#C4D318', '#50284A' ) );
		$bar_stack->set_keys(array(
			new bar_stack_key( '#C4D318', 'Ya', 13 ),
			new bar_stack_key( '#50284A', 'Tidak', 13 )
		));

		$highest = 0;
		
		//get month between
		for($i = 1; $i <= 11; $i++){
			$first_datetime = $year.'-'.$i.'-01';
			$end_datetime = plus_month($first_datetime, 1);
			$countSatisfied = $this->questionmodel->get_countsatisfy_question($question_id, $first_datetime.' '.$starttime, $end_datetime.' '.$starttime, false, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			$countNotSatisfied = $this->questionmodel->get_countunsatisfy_question($question_id, $first_datetime.' '.$starttime, $end_datetime.' '.$starttime, false, ($plasa_id > 0 ? $plasa_id : null), ($csr_id > 0 ? $csr_id : null));
			
			if ($countNotSatisfied + $countSatisfied > $highest) $highest = $countNotSatisfied + $countSatisfied + 3;
			$bar_stack->append_stack(array($countSatisfied,$countNotSatisfied));
		}

		$bar_stack->append_stack(array($countSatisfied,$countNotSatisfied));
		
		$bar_stack->set_tooltip( '[#x_label#]<br>#val# dari #total# responder' );

		$animation='pop'; $delay=0; $cascade=1;
		$bar_stack->set_on_show(new bar_on_show($animation, $cascade, $delay));

		$y = new y_axis();
		$y->set_range( 0, roundup_integer($highest), 10 );


		$x_labels = new x_axis_labels();
		$x_labels->rotate(20);
		$x_labels->set_labels(get_array_month(LANG_INDONESIA));
		$x = new x_axis();
		$x->set_labels($x_labels);

		$tooltip = new tooltip();
		$tooltip->set_hover();

		$chart = new open_flash_chart();
		$chart->set_title( $title );
		$chart->add_element( $bar_stack );
		$chart->set_x_axis( $x );
		$chart->add_y_axis( $y );
		$chart->set_tooltip( $tooltip );

		echo $chart->toPrettyString();
	}
			
	function ofc_upload_image($timeType, $param1, $param2, $param3, $plasa_id = 0, $csr_id = 0, $filename = 'file.png', $redirect = false, $to_excel = "false"){		
		$default_path = realpath('assets/img/temp_chart');
		
		if (!file_exists($default_path)) mkdir($default_path, 0777, true);

		$destination = $default_path .DIRECTORY_SEPARATOR. basename( $filename ); 

		$post = file_get_contents('php://input');

		$jfh = fopen($destination, 'w') or die("can't open file");
		fwrite($jfh, $post);
		fclose($jfh);

		if($redirect)	$this->report($timeType, $param1, $param2, $param3, $plasa_id, $csr_id, $to_excel);
		else exit();
	}
	
	//function report($question_id, $from, $to){
	function report($timeType, $param1, $param2, $param3, $plasa_id = 0, $csr_id = 0, $to_excel = "false"){
		$question_id = ($timeType == 2 ? $param2 : $param3);
		
		$question = $this->questionmodel->get_info_question($question_id)->row();
		
		$selected_plasa = 0;
		$plasa_name = '';
		$csr_name = '';
		
		if($this->session->userdata('is_super_admin'))	$selected_plasa = $plasa_id;
		else if($this->session->userdata('is_admin'))	$selected_plasa = $this->session->userdata('is_admin'); 
		else if($this->session->userdata('is_pic'))	$selected_plasa = $this->session->userdata('is_pic');
		
		if($selected_plasa > 0) {
			$plasa_name = $this->plasamodel->get_plasa_info($selected_plasa)->row()->name;
			if($csr_id > 0) {
				$csr_name = $this->csrmodel->get_csr_info($csr_id)->row()->name;
			}
		}
		
		$timestamp = ' (';
		if($timeType == 0) $timestamp .= $param1.' - '.$param2;
		if($timeType == 1) $timestamp .= 'Bulan '.get_month_name($param1, LANG_INDONESIA).' '.$param2;
		if($timeType == 2) $timestamp .= 'Tahun '.$param1;
		$timestamp .= ')';
		
		$param['title'] = $question->content.$timestamp;
		$param['plasa_name'] = $plasa_name;
		$param['csr_name'] = $csr_name;
		$param['filename'] = 'Plasa '.$plasa_name.$timestamp.' -'.$question->content;
		$param['img_url_pie'] = base_url().PERMANENT_GRAPH_IMAGE_ADDRESS_PIE;
		$param['img_url_bar'] = base_url().PERMANENT_GRAPH_IMAGE_ADDRESS_BAR;
		$param['timeType'] = $timeType;
		
		$param['data_table'] = $this->get_data_table($timeType, $param1, $param2, $param3, $plasa_id, $csr_id, false);
		
		if($to_excel == "true"){
			$this->load->view('admin/report_excel',$param);
		}else{
			$this->load->view('admin/report',$param);
		}
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */